<template>
  <div>
    <el-card id="top_card" class="top_nav_caseOrder" :shadow="shadowShow">
      <el-form label-width="135px" :inline="true" :size="formItemSize">
        <el-form-item>
          <el-input v-model="form.doctorName" clearable :placeholder="$t('caseorder.anli65')"
            @keyup.enter.native="getSelectPageList" />
        </el-form-item>

        <el-form-item v-show="user_organizedType == 1">
          <el-input v-model="form.skillDeptName" clearable :placeholder="$t('caseorder.anli66')"
            @keyup.enter.native="getSelectPageList" />
        </el-form-item>

        <el-form-item v-show="user_organizedType == 2">
          <el-input v-model="form.creatorDeptName" clearable :placeholder="$t('caseorder.anli69')"
            @keyup.enter.native="getSelectPageList" />
        </el-form-item>

        <el-form-item>
          <el-input v-model="form.patientName" clearable :placeholder="$t('caseorder.anli67')"
            @keyup.enter.native="getSelectPageList" />
        </el-form-item>

        <el-form-item :label="$t('caseorder.anli2') + '：'">
          <el-select v-model="form.orderDataType" clearable filterable allow-create default-first-option
            :placeholder="$t('caseorder.anli2')">
            <el-option v-for="item in cateOptions" :key="item.value" :label="item.label" :value="item.value" />
          </el-select>
        </el-form-item>
        <el-form-item :label="$t('caseorder.anli3') + '：'">
          <el-date-picker v-model="dateTime" :picker-options="pickerOptions" type="daterange" range-separator="~"
            value-format="yyyy-MM-dd" :start-placeholder="$t('caseorder.anli4')"
            :end-placeholder="$t('caseorder.anli5')" />
        </el-form-item>
        <!-- <el-form-item label="转换状态：">
            <el-checkbox v-model="form.checked"></el-checkbox>
</el-form-item>-->
        <el-form-item>
          <el-button type="primary" :size="optionButtonSize" @click="getSelectPageList">
            {{ $t('caseorder.anli7') }}
          </el-button>
          <el-button plain :size="optionButtonSize" @click="resetClick">{{ $t('caseorder.anli8') }}
          </el-button>
        </el-form-item>
      </el-form>
    </el-card>

    <el-card :shadow="shadowShow" style="margin-top: 20px" id="content_card">
      <el-tabs v-model="activeName" type="border-card" class="order_card" @tab-click="tabHandleClick">
        <el-tab-pane :label="$t('caseorder.all')" name="quanbu" />
        <el-tab-pane v-if="user_organizedType == 1" :label="$t('caseorder.staging')" name="zancun" />
        <el-tab-pane :label="$t('caseorder.pendingOrder')" name="daijiedan" />
        <el-tab-pane :label="$t('add.add14')" name="yijiedan" />
        <el-tab-pane :label="$t('add.add16')" name="daiquerenseji" />
        <el-tab-pane :label="$t('add.add15')" name="daisheji" />
        <el-tab-pane :label="$t('add.add17')" name="yiquerensheji" />
        <el-tab-pane :label="$t('add.add18')" name="daifahuo" />
        <el-tab-pane :label="$t('add.add19')" name="daishouhuo" />
        <el-tab-pane :label="$t('add.add22')" name="yiwancheng" />
        <el-tab-pane :label="$t('add.add21')" name="yiquxiao" />
        <el-tab-pane :label="$t('add.add20')" name="yijujue" />
      </el-tabs>
      <template>
        <el-table height="550" ref="multipleTable" :data="tableData" tooltip-effect="dark" style="width: 100%"
          @selection-change="handleSelectionChange">
          <!-- <el-table-column prop="orderCreateTime" :label="$t('caseorder.anli9')" width="160"></el-table-column> -->
          <el-table-column prop="createDate" :label="$t('caseorder.anli9')" align="center" />

          <el-table-column prop="doctorName" :label="$t('caseorder.anli10')" align="center" />
          <el-table-column prop="creatorDeptName" :label="$t('caseorder.anli11')" align="center" />
          <el-table-column prop="skillDeptName" :label="$t('caseorder.anli12')" align="center" />
          <!-- anli13 患者 -->
          <el-table-column prop="patientName" :label="$t('caseorder.anli13')" align="center" />
          <el-table-column prop="orderTypeName" align="center" :label="$t('caseorder.anli14')" />
          <el-table-column prop="id" align="center" :label="$t('caseorder.anli64')" />
          <el-table-column :label="$t('add.add11')" align="center" prop="orderStatus">
            <template slot-scope="scope">
              <span v-if="user_organizedType == 1">
                <span v-if="scope.row.orderStatus == 0">{{ $t('add.add12') }}</span>
                <span v-if="scope.row.orderStatus == 1">{{ $t('add.add13') }}</span>
                <span v-if="scope.row.orderStatus == 2">
                  {{ $t('add.add14') }}
                  <!-- 待设计 -->
                </span>
                <span v-if="scope.row.orderStatus == 3 && scope.row.orderDesignStatus == 'AGAIN'">{{
                  $t('add.add15')
                }}</span>
                <span v-if="scope.row.orderDesignStatus == 'EXIST' && scope.row.orderStatus == 3">{{
                  $t('add.add16')
                }}</span>
                <span v-if="scope.row.orderDesignStatus == 'AFFIRM' && scope.row.orderStatus == 3">{{ $t('add.add17')
                  }}</span>
                <span v-if="scope.row.orderLogisticsStatus == 'AGAIN' && scope.row.orderStatus == 8">{{ $t('add.add18')
                  }}</span>
                <span v-if="scope.row.orderLogisticsStatus == 'EXIST' && scope.row.orderStatus == 8">{{ $t('add.add19')
                  }}</span>
                <span v-if="scope.row.orderStatus == 4">{{ $t('add.add20') }}</span>
                <span v-if="scope.row.orderStatus == 5">{{ $t('add.add145') }}</span>
                <span v-if="scope.row.orderStatus == 6">{{ $t('add.add22') }}</span>
                <span v-if="scope.row.orderStatus == -1">{{ $t('add.add062') }}</span>
                <span v-if="scope.row.orderStatus == 10">{{ $t('add.add078') }}</span>
              </span>
              <span v-if="user_organizedType == 2">
                <span v-if="scope.row.orderStatus == 0">{{ $t('add.add12') }}</span>
                <span v-if="scope.row.orderStatus == 1">{{ $t('add.add13') }}</span>
                <span v-if="scope.row.orderStatus == 2">
                  {{ $t('add.add14') }}
                  <!-- 待设计 -->
                </span>
                <!-- scope.row.orderStatus == 3 && scope.row.orderDesignStatus == 'AGAIN' 诊所 带设计 技工所 待确认设计-->
                <span v-if="scope.row.orderStatus == 3 && scope.row.orderDesignStatus == 'AGAIN'">{{
                  $t('add.add23')
                }}</span>
                <span v-if="scope.row.orderDesignStatus == 'EXIST' && scope.row.orderStatus == 3">{{
                  $t('add.add16')
                }}</span>
                <span v-if="scope.row.orderDesignStatus == 'AFFIRM' && scope.row.orderStatus == 3">{{ $t('add.add17')
                  }}</span>
                <span v-if="scope.row.orderLogisticsStatus == 'AGAIN' && scope.row.orderStatus == 8">{{ $t('add.add18')
                  }}</span>
                <span v-if="scope.row.orderLogisticsStatus == 'EXIST' && scope.row.orderStatus == 8">{{ $t('add.add19')
                  }}</span>
                <span v-if="scope.row.orderStatus == 4">{{ $t('add.add20') }}</span>
                <span v-if="scope.row.orderStatus == 5">{{ $t('add.add145') }}</span>
                <span v-if="scope.row.orderStatus == 6">{{ $t('add.add22') }}</span>
                <span v-if="scope.row.orderStatus == -1">{{ $t('add.add062') }}</span>
                <span v-if="scope.row.orderStatus == 10">{{ $t('add.add078') }}</span>
              </span>
              <!-- <span v-if="activeName == 'seji'">
                  <span v-if="scope.row.orderDesignStatus == 'EXIST'">{{
                      $t('caseorder.anli16') }}</span>
                  <span v-if="scope.row.orderDesignStatus == 'AGAIN'">{{
                      $t('caseorder.anli17') }}</span>
                  <span v-if="scope.row.orderDesignStatus == 'AFFIRM'">{{
                      $t('caseorder.anli18') }}</span>
                  <span v-if="scope.row.orderDesignStatus == ''">{{
                      $t('caseorder.anli19')
                  }}</span>
              </span>
              <span v-if="activeName == 'wuliu'">
                  <span v-if="scope.row.orderLogisticsStatus == 'EXIST'">
                      有物流
                  </span>
                  <span v-if="scope.row.orderLogisticsStatus == 'AGAIN'">
                      重新发货
                  </span>
                  <span v-if="scope.row.orderLogisticsStatus == 'AFFIRM'">
                      确认收货
                  </span>
</span>-->
            </template>
          </el-table-column>
          <!-- <el-table-column v-if="activeName == 'wuliu'" label="物流状态"></el-table-column> -->
          <el-table-column prop="doctor" :label="$t('add.add131')" header-align="center" width="240">
            <!-- 0:全部 1:待接单, 0:暂存,待设计 3:有设计,待发货, 4:拒绝接单 5:已取消 6:订单完成 7:其他 8:已发货不能删,有物流 -->
            <template v-if="scope.row.orderStatus !== -1" slot-scope="scope" class="order_handle"
              style="border: 1px solid black">
              <!-- 诊所 -->
              <div v-if="user_organizedType == 1" style="display: flex">
                <!-- 暂存 -->
                <div v-if="scope.row.orderStatus == 0">
                  <!-- 预览 -->
                  <el-button type="text" :size="tableButtonSize" @click="orderHandle(scope.$index, scope.row, 'see')">
                    {{ $t('caseorder.anli20') }}
                  </el-button>
                  <!-- 下单 -->
                  <el-button type="text" :size="tableButtonSize"
                    @click="orderHandle(scope.$index, scope.row, 'xiadan')">
                    {{ $t('caseorder.anli23') }}
                  </el-button>
                  <!-- 取消订单 -->
                  <el-button slot="reference" type="text" :size="tableButtonSize"
                    @click="orderHandle(scope.$index, scope.row, 'cancle')">
                    {{ $t('caseorder.anli24') }}
                  </el-button>
                  <el-button type="text" :size="tableButtonSize"
                    @click="orderHandle(scope.$index, scope.row, 'delete')">
                    {{ $t('caseorder.anli32') }}
                  </el-button>
                </div>
                <!-- 待接单 -->
                <div v-if="scope.row.orderStatus == 1">
                  <!-- 预览 -->
                  <el-button type="text" :size="tableButtonSize" @click="orderHandle(scope.$index, scope.row, 'see')">
                    {{ $t('caseorder.anli20') }}
                  </el-button>
                  <!-- 取消订单 -->
                  <el-button slot="reference" type="text" :size="tableButtonSize"
                    @click="orderHandle(scope.$index, scope.row, 'cancle')">
                    {{ $t('caseorder.anli24') }}
                  </el-button>
                </div>
                <!-- 已接单 -->
                <div v-if="scope.row.orderStatus == 2">
                  <!-- 预览 -->
                  <el-button type="text" :size="tableButtonSize" @click="orderHandle(scope.$index, scope.row, 'see')">
                    {{ $t('caseorder.anli20') }}
                  </el-button>
                  <!-- 取消订单 -->
                  <el-button slot="reference" type="text" :size="tableButtonSize"
                    @click="orderHandle(scope.$index, scope.row, 'cancle')">
                    {{ $t('caseorder.anli24') }}
                  </el-button>
                </div>
                <!-- 待设计 和已接单一样 -->
                <!-- <div v-if="scope.row.orderStatus == 2">
</div>-->
                <!-- 待确认设计 -->
                <div v-if="scope.row.orderDesignStatus == 'EXIST' && scope.row.orderStatus == 3">
                  <!-- 预览 -->
                  <el-button type="text" :size="tableButtonSize" @click="orderHandle(scope.$index, scope.row, 'see')">
                    {{ $t('caseorder.anli20') }}
                  </el-button>
                  <!-- 设计管理 -->
                  <el-dropdown size @command="handleCommand">
                    <span class="el-dropdown-link">
                      {{ $t('caseorder.anli26') }}
                      <i class="el-icon-arrow-down el-icon--right"></i>
                    </span>
                    <el-dropdown-menu slot="dropdown">
                      <!-- 确认设计 -->
                      <el-dropdown-item :command="beforeHandleCommand(scope.row.id, 'a')">
                        {{ $t('caseorder.anli27') }}
                      </el-dropdown-item>
                      <!-- 重新设计 -->
                      <el-dropdown-item :command="beforeHandleCommand(scope.row.id, 'b')">
                        {{ $t('caseorder.anli28') }}
                      </el-dropdown-item>
                    </el-dropdown-menu>
                  </el-dropdown>
                  <!-- 取消订单 -->
                  <el-button slot="reference" type="text" :size="tableButtonSize"
                    @click="orderHandle(scope.$index, scope.row, 'cancle')">
                    {{ $t('caseorder.anli24') }}
                  </el-button>
                </div>
                <!-- 已确认设计 -->
                <div v-if="scope.row.orderDesignStatus == 'AFFIRM' && scope.row.orderStatus == 3">
                  <!-- 预览 -->
                  <el-button type="text" :size="tableButtonSize" @click="orderHandle(scope.$index, scope.row, 'see')">
                    {{ $t('caseorder.anli20') }}
                  </el-button>
                  <!-- 取消订单 -->
                  <el-button slot="reference" type="text" :size="tableButtonSize"
                    @click="orderHandle(scope.$index, scope.row, 'cancle')">
                    {{ $t('caseorder.anli24') }}
                  </el-button>
                </div>
                <!-- 重新设计 -->
                <div v-if="scope.row.orderDesignStatus == 'AGAIN' && scope.row.orderStatus == 3">
                  <!-- 预览 -->
                  <el-button type="text" :size="tableButtonSize" @click="orderHandle(scope.$index, scope.row, 'see')">
                    {{ $t('caseorder.anli20') }}
                  </el-button>
                  <!-- 取消订单 -->
                  <el-button slot="reference" type="text" :size="tableButtonSize"
                    @click="orderHandle(scope.$index, scope.row, 'cancle')">
                    {{ $t('caseorder.anli24') }}
                  </el-button>
                </div>
                <!-- 待发货 -->
                <div v-if="scope.row.orderLogisticsStatus == 'AGAIN' && scope.row.orderStatus == 8">
                  <el-button type="text" :size="tableButtonSize" @click="orderHandle(scope.$index, scope.row, 'see')">
                    {{ $t('caseorder.anli20') }}
                  </el-button>
                  <el-button slot="reference" type="text" :size="tableButtonSize"
                    @click="orderHandle(scope.$index, scope.row, 'cancle')">
                    {{ $t('caseorder.anli24') }}
                  </el-button>
                </div>
                <!-- 待收货 -->
                <div v-if="scope.row.orderLogisticsStatus == 'EXIST' && scope.row.orderStatus == 8">
                  <!-- 预览 -->
                  <el-button type="text" :size="tableButtonSize" @click="orderHandle(scope.$index, scope.row, 'see')">
                    {{ $t('caseorder.anli20') }}
                  </el-button>
                  <el-dropdown size @command="handleCommand">
                    <span class="el-dropdown-link">
                      <!-- 收发货管理 -->
                      {{ $t('caseorder.anli29') }}
                      <i class="el-icon-arrow-down el-icon--right"></i>
                    </span>
                    <el-dropdown-menu slot="dropdown">
                      <!-- 确认收货 -->
                      <el-dropdown-item :command="beforeHandleCommand(scope.row.id, 'c')">
                        {{ $t('caseorder.anli30') }}
                      </el-dropdown-item>
                      <!-- 重新发货 -->
                      <el-dropdown-item :command="beforeHandleCommand(scope.row.id, 'd')">
                        {{ $t('caseorder.anli31') }}
                      </el-dropdown-item>
                    </el-dropdown-menu>
                  </el-dropdown>
                </div>
                <!-- 重新发货 预览 取消-->
                <!-- 已完成 -->
                <div v-if="scope.row.orderStatus == 6">
                  <!-- 预览 -->
                  <el-button type="text" :size="tableButtonSize" @click="orderHandle(scope.$index, scope.row, 'see')">
                    {{ $t('caseorder.anli20') }}
                  </el-button>
                </div>
                <!-- 已取消 -->
                <div v-if="scope.row.orderStatus == 5">
                  <!-- 预览 -->
                  <el-button type="text" :size="tableButtonSize" @click="orderHandle(scope.$index, scope.row, 'see')">
                    {{ $t('caseorder.anli20') }}
                  </el-button>
                </div>
                <!-- 已拒绝 -->
                <div v-if="scope.row.orderStatus == 4">
                  <!-- 预览 -->
                  <el-button type="text" :size="tableButtonSize" @click="orderHandle(scope.$index, scope.row, 'see')">
                    {{ $t('caseorder.anli20') }}
                  </el-button>
                  <!-- 重新下单 -->
                  <el-button slot="reference" type="text" :size="tableButtonSize"
                    @click="orderHandle(scope.$index, scope.row, 'xiadan')">
                    {{ $t('caseorder.anli25') }}
                  </el-button>
                  <!-- 取消订单 -->
                  <el-button slot="reference" type="text" :size="tableButtonSize"
                    @click="orderHandle(scope.$index, scope.row, 'cancle')">
                    {{ $t('caseorder.anli24') }}
                  </el-button>
                  <!-- 删除 -->
                  <el-button type="text" :size="tableButtonSize"
                    @click="orderHandle(scope.$index, scope.row, 'delete')">
                    {{ $t('caseorder.anli32') }}
                  </el-button>
                </div>
                <!-- 删除 所有者 管理员 只有暂存、已完成、已取消、已拒绝状态的订单可以删除 -->
                <div v-if="
                  (user_owner == 1 &&
                    (scope.row.orderStatus == 6 || scope.row.orderStatus == 5)) ||
                  (user_roleId == 2 &&
                    (scope.row.orderStatus == 6 || scope.row.orderStatus == 5)) ||
                  (user_roleId == 4 && (scope.row.orderStatus == 6 || scope.row.orderStatus == 5))
                ">
                  <el-button type="text" :size="tableButtonSize"
                    @click="orderHandle(scope.$index, scope.row, 'delete')">
                    {{ $t('caseorder.anli32') }}
                  </el-button>
                </div>
              </div>
              <!-- 技工所 -->
              <div v-if="user_organizedType == 2">
                <!-- 发送端是诊所 -->
                <div v-if="scope.row.skillDeptId != scope.row.creatorDeptId" style="display: flex">
                  <!-- 待接单 -->
                  <div v-if="scope.row.orderStatus == 1">
                    <!-- 预览 -->
                    <el-button type="text" :size="tableButtonSize" @click="orderHandle(scope.$index, scope.row, 'see')">
                      {{ $t('caseorder.anli20') }}
                    </el-button>
                    <!-- 确认接单 -->
                    <el-button type="text" :size="tableButtonSize" @click="orderAffirm(scope.row)">
                      {{ $t('caseorder.yulan.yulan29') }}
                    </el-button>
                    <!-- 拒绝接单 -->
                    <el-button type="text" :size="tableButtonSize" @click="orderReject(scope.row.id)">
                      {{ $t('caseorder.yulan.yulan28') }}
                    </el-button>
                  </div>
                  <!-- 已接单 -->
                  <div v-if="scope.row.orderStatus == 2">
                    <!-- 预览 -->
                    <el-button type="text" :size="tableButtonSize" @click="orderHandle(scope.$index, scope.row, 'see')">
                      {{ $t('caseorder.anli20') }}
                    </el-button>
                    <!-- 上传设计 -->
                    <el-button v-if="!scope.row.orderDesignAutoCheck" type="text" :size="tableButtonSize"
                      @click="orderHandle(scope.$index, scope.row, 'upload')">
                      {{ $t('caseorder.anli21') }}
                    </el-button>
                    <!-- 发货 -->
                    <el-button v-if="scope.row.orderDesignAutoCheck" type="text" :size="tableButtonSize"
                      @click="orderHandle(scope.$index, scope.row, 'send')">
                      {{ $t('caseorder.anli22') }}
                    </el-button>
                  </div>
                  <!-- 重新设计 -->
                  <div v-if="scope.row.orderStatus == 3 && scope.row.orderDesignStatus == 'AGAIN'">
                    <!-- 预览 -->
                    <el-button type="text" :size="tableButtonSize" @click="orderHandle(scope.$index, scope.row, 'see')">
                      {{ $t('caseorder.anli20') }}
                    </el-button>
                    <!-- 上传设计 -->
                    <el-button v-if="!scope.row.orderDesignAutoCheck" type="text" :size="tableButtonSize"
                      @click="orderHandle(scope.$index, scope.row, 'upload')">
                      {{ $t('caseorder.anli21') }}
                    </el-button>
                  </div>
                  <!-- 待确认设计 -->
                  <div v-if="scope.row.orderDesignStatus == 'EXIST' && scope.row.orderStatus == 3">
                    <!-- 预览 -->
                    <el-button type="text" :size="tableButtonSize" @click="orderHandle(scope.$index, scope.row, 'see')">
                      {{ $t('caseorder.anli20') }}
                    </el-button>
                    <!-- 上传设计 -->
                    <el-button type="text" :size="tableButtonSize"
                      @click="orderHandle(scope.$index, scope.row, 'upload')">
                      {{ $t('caseorder.anli21') }}
                    </el-button>
                  </div>
                  <!-- 已确认设计 -->
                  <div v-if="scope.row.orderDesignStatus == 'AFFIRM' && scope.row.orderStatus == 3">
                    <!-- 预览 -->
                    <el-button type="text" :size="tableButtonSize" @click="orderHandle(scope.$index, scope.row, 'see')">
                      {{ $t('caseorder.anli20') }}
                    </el-button>
                    <!-- 发货 -->
                    <el-button type="text" :size="tableButtonSize"
                      @click="orderHandle(scope.$index, scope.row, 'send')">
                      {{ $t('caseorder.anli22') }}
                    </el-button>
                  </div>
                  <!-- 待发货 -->
                  <div v-if="scope.row.orderLogisticsStatus == 'AGAIN' && scope.row.orderStatus == 8">
                    <!-- 预览 -->
                    <el-button type="text" :size="tableButtonSize" @click="orderHandle(scope.$index, scope.row, 'see')">
                      {{ $t('caseorder.anli20') }}
                    </el-button>
                    <!-- 发货 -->
                    <el-button type="text" :size="tableButtonSize"
                      @click="orderHandle(scope.$index, scope.row, 'send')">
                      {{ $t('caseorder.anli22') }}
                    </el-button>
                  </div>
                  <!-- 待收货 -->
                  <div v-if="scope.row.orderLogisticsStatus == 'EXIST' && scope.row.orderStatus == 8">
                    <!-- 预览 -->
                    <el-button type="text" :size="tableButtonSize" @click="orderHandle(scope.$index, scope.row, 'see')">
                      {{ $t('caseorder.anli20') }}
                    </el-button>
                  </div>
                  <!-- 已完成 -->
                  <div v-if="scope.row.orderStatus == 6">
                    <!-- 预览 -->
                    <el-button type="text" :size="tableButtonSize" @click="orderHandle(scope.$index, scope.row, 'see')">
                      {{ $t('caseorder.anli20') }}
                    </el-button>
                    <!-- 删除 -->
                    <el-button type="text" :size="tableButtonSize"
                      @click="orderHandle(scope.$index, scope.row, 'delete')">
                      {{ $t('caseorder.anli32') }}
                    </el-button>
                  </div>
                  <!-- 已取消 无操作 -->
                  <div v-if="scope.row.orderStatus == 5"></div>
                  <!-- 已拒绝 -->
                  <div v-if="scope.row.orderStatus == 4">
                    <!-- 预览 -->
                    <el-button type="text" :size="tableButtonSize" @click="orderHandle(scope.$index, scope.row, 'see')">
                      {{ $t('caseorder.anli20') }}
                    </el-button>
                  </div>
                  <!-- 删除 所有者 管理员 只有暂存、已完成、已取消、已拒绝状态的订单可以删除 -->
                  <div v-if="
                    (user_owner == 1 &&
                      (scope.row.orderStatus == 0 ||
                        scope.row.orderStatus == 5 ||
                        scope.row.orderStatus == 4)) ||
                    (user_roleId == 2 &&
                      (scope.row.orderStatus == 0 ||
                        scope.row.orderStatus == 5 ||
                        scope.row.orderStatus == 4)) ||
                    (user_roleId == 4 &&
                      (scope.row.orderStatus == 0 ||
                        scope.row.orderStatus == 5 ||
                        scope.row.orderStatus == 4))
                  ">
                    <el-button type="text" :size="tableButtonSize"
                      @click="orderHandle(scope.$index, scope.row, 'delete')">
                      {{ $t('caseorder.anli32') }}
                    </el-button>
                  </div>
                </div>
                <!-- 发送端是技工所 -->
                <div v-if="scope.row.skillDeptId == scope.row.creatorDeptId" style="display: flex">
                  <!-- 待接单 -->
                  <div v-if="scope.row.orderStatus == 1">
                    <!-- 预览 -->
                    <el-button type="text" :size="tableButtonSize" @click="orderHandle(scope.$index, scope.row, 'see')">
                      {{ $t('caseorder.anli20') }}
                    </el-button>
                    <!-- 确认接单 -->
                    <el-button type="text" :size="tableButtonSize" @click="orderAffirm(scope.row)">
                      {{ $t('caseorder.yulan.yulan29') }}
                    </el-button>
                    <!-- 拒绝接单 -->
                    <el-button type="text" :size="tableButtonSize" @click="orderReject(scope.row.id)">
                      {{ $t('caseorder.yulan.yulan28') }}
                    </el-button>
                  </div>
                  <!-- 已接单 -->
                  <div v-if="scope.row.orderStatus == 2">
                    <!-- 预览 -->
                    <el-button type="text" :size="tableButtonSize" @click="orderHandle(scope.$index, scope.row, 'see')">
                      {{ $t('caseorder.anli20') }}
                    </el-button>
                    <!-- 上传设计 -->
                    <el-button v-if="!scope.row.orderDesignAutoCheck" type="text" :size="tableButtonSize"
                      @click="orderHandle(scope.$index, scope.row, 'upload')">
                      {{ $t('caseorder.anli21') }}
                    </el-button>
                    <!-- 发货 -->
                    <el-button v-if="scope.row.orderDesignAutoCheck" type="text" :size="tableButtonSize"
                      @click="orderHandle(scope.$index, scope.row, 'send')">
                      {{ $t('caseorder.anli22') }}
                    </el-button>
                  </div>
                  <!-- 重新设计 -->
                  <div v-if="scope.row.orderStatus == 3 && scope.row.orderDesignStatus == 'AGAIN'">
                    <!-- 预览 -->
                    <el-button type="text" :size="tableButtonSize" @click="orderHandle(scope.$index, scope.row, 'see')">
                      {{ $t('caseorder.anli20') }}
                    </el-button>
                    <!-- 上传设计 -->
                    <el-button v-if="!scope.row.orderDesignAutoCheck" type="text" :size="tableButtonSize"
                      @click="orderHandle(scope.$index, scope.row, 'upload')">
                      {{ $t('caseorder.anli21') }}
                    </el-button>
                  </div>
                  <!-- 待确认设计 -->
                  <div v-if="scope.row.orderDesignStatus == 'EXIST' && scope.row.orderStatus == 3">
                    <!-- 预览 -->
                    <el-button type="text" :size="tableButtonSize" @click="orderHandle(scope.$index, scope.row, 'see')">
                      {{ $t('caseorder.anli20') }}
                    </el-button>
                    <!-- 设计管理 -->
                    <el-dropdown size @command="handleCommand">
                      <span class="el-dropdown-link">
                        {{ $t('caseorder.anli26') }}
                        <i class="el-icon-arrow-down el-icon--right"></i>
                      </span>
                      <el-dropdown-menu slot="dropdown">
                        <!-- 确认设计 -->
                        <el-dropdown-item :command="beforeHandleCommand(scope.row.id, 'a')">
                          {{ $t('caseorder.anli27') }}
                        </el-dropdown-item>
                        <!-- 重新设计 -->
                        <el-dropdown-item :command="beforeHandleCommand(scope.row.id, 'b')">
                          {{ $t('caseorder.anli28') }}
                        </el-dropdown-item>
                      </el-dropdown-menu>
                    </el-dropdown>
                    <!-- 上传设计 -->
                    <el-button type="text" :size="tableButtonSize"
                      @click="orderHandle(scope.$index, scope.row, 'upload')">
                      {{ $t('caseorder.anli21') }}
                    </el-button>
                  </div>
                  <!-- 已确认设计 -->
                  <div v-if="scope.row.orderDesignStatus == 'AFFIRM' && scope.row.orderStatus == 3">
                    <!-- 预览 -->
                    <el-button type="text" :size="tableButtonSize" @click="orderHandle(scope.$index, scope.row, 'see')">
                      {{ $t('caseorder.anli20') }}
                    </el-button>
                    <!-- 发货 -->
                    <el-button type="text" :size="tableButtonSize"
                      @click="orderHandle(scope.$index, scope.row, 'send')">
                      {{ $t('caseorder.anli22') }}
                    </el-button>
                  </div>
                  <!-- 待发货 -->
                  <div v-if="scope.row.orderLogisticsStatus == 'AGAIN' && scope.row.orderStatus == 8">
                    <!-- 预览 -->
                    <el-button type="text" :size="tableButtonSize" @click="orderHandle(scope.$index, scope.row, 'see')">
                      {{ $t('caseorder.anli20') }}
                    </el-button>
                    <!-- 发货 -->
                    <el-button type="text" :size="tableButtonSize"
                      @click="orderHandle(scope.$index, scope.row, 'send')">
                      {{ $t('caseorder.anli22') }}
                    </el-button>
                  </div>
                  <!-- 待收货 -->
                  <div v-if="scope.row.orderLogisticsStatus == 'EXIST' && scope.row.orderStatus == 8">
                    <!-- 预览 -->
                    <el-button type="text" :size="tableButtonSize" @click="orderHandle(scope.$index, scope.row, 'see')">
                      {{ $t('caseorder.anli20') }}
                    </el-button>
                    <el-dropdown size @command="handleCommand">
                      <span class="el-dropdown-link">
                        <!-- 收发货管理 -->
                        {{ $t('caseorder.anli29') }}
                        <i class="el-icon-arrow-down el-icon--right"></i>
                      </span>
                      <el-dropdown-menu slot="dropdown">
                        <!-- 确认收货 -->
                        <el-dropdown-item :command="beforeHandleCommand(scope.row.id, 'c')">
                          {{ $t('caseorder.anli30') }}
                        </el-dropdown-item>
                        <!-- 重新发货 -->
                        <el-dropdown-item :command="beforeHandleCommand(scope.row.id, 'd')">
                          {{ $t('caseorder.anli31') }}
                        </el-dropdown-item>
                      </el-dropdown-menu>
                    </el-dropdown>
                  </div>
                  <!-- 已完成 -->
                  <div v-if="scope.row.orderStatus == 6">
                    <!-- 预览 -->
                    <el-button type="text" :size="tableButtonSize" @click="orderHandle(scope.$index, scope.row, 'see')">
                      {{ $t('caseorder.anli20') }}
                    </el-button>
                    <!-- 删除 -->
                    <el-button type="text" :size="tableButtonSize"
                      @click="orderHandle(scope.$index, scope.row, 'delete')">
                      {{ $t('caseorder.anli32') }}
                    </el-button>
                  </div>
                  <!-- 已拒绝 -->
                  <div v-if="scope.row.orderStatus == 4">
                    <!-- 预览 -->
                    <el-button type="text" :size="tableButtonSize" @click="orderHandle(scope.$index, scope.row, 'see')">
                      {{ $t('caseorder.anli20') }}
                    </el-button>
                  </div>
                  <!-- 删除 所有者 管理员 只有暂存、已完成、已取消、已拒绝状态的订单可以删除 -->
                  <div v-if="
                    (user_owner == 1 &&
                      (scope.row.orderStatus == 0 ||
                        scope.row.orderStatus == 5 ||
                        scope.row.orderStatus == 4)) ||
                    (user_roleId == 2 &&
                      (scope.row.orderStatus == 0 ||
                        scope.row.orderStatus == 5 ||
                        scope.row.orderStatus == 4)) ||
                    (user_roleId == 4 &&
                      (scope.row.orderStatus == 0 ||
                        scope.row.orderStatus == 5 ||
                        scope.row.orderStatus == 4))
                  ">
                    <el-button type="text" :size="tableButtonSize"
                      @click="orderHandle(scope.$index, scope.row, 'delete')">
                      {{ $t('caseorder.anli32') }}
                    </el-button>
                  </div>
                </div>
              </div>
            </template>
          </el-table-column>
        </el-table>
        <div v-if="tableData.length > 0" style="margin: 16px 0; float: right">
          <el-pagination background :current-page.sync="form.page" :page-sizes="[10, 20, 50, 100]"
            :page-size="form.limit" :total="total" layout="total, sizes, prev, pager, next, jumper"
            @size-change="handleSizeChange" @current-change="handleCurrentChange" />
        </div>
      </template>
    </el-card>
    <!-- <el-dialog :title="$t('caseorder.anli33')" :visible.sync="jgsdialogShow">
      <div class="orderSend_inner">
        <el-form
          ref="jgsform"
          :size="optionButtonSize"
          label-position="top"
          label-width="100px"
          :model="form"
        >
          <el-form-item :label="$t('caseorder.anli34') + '：'" prop>
            <el-select
              v-model="jgsform.skillDeptId"
              clearable
              style="width: 370px"
              :placeholder="$t('caseorder.anli35')"
            >
              <el-option
                v-for="(item, index) in deptList"
                :key="index"
                :label="item.name"
                :value="item.id"
              />
            </el-select>
          </el-form-item>
        </el-form>
      </div>

      <div slot="footer" class="dialog-footer">
        <el-button size="small" @click="jgsdialogShow = false"
          >{{ $t('caseorder.anli36') }}
        </el-button>
        <el-button size="small" type="primary" @click="submitHandle()"
          >{{ $t('caseorder.anli37') }}
        </el-button>
      </div>
    </el-dialog> -->
    <!-- 上传设计 -->
    <UploadDesigns ref="uploaddesigns" @getSelectPageList="getSelectPageList" />
    <OrderSend ref="ordersend" @getSelectPageList="getSelectPageList" />

    <el-dialog :title="$t('add.add29')" :visible.sync="dialogVisible" width="30%" :close-on-click-modal="false">
      <div>
        <p style="text-align: center">{{ $t('add.add074') }}</p>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">
          {{ $t('add.add31') }}
        </el-button>
        <el-button type="primary" @click="toDownload()">
          {{ $t('add.add075') }}
        </el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import UploadDesigns from './uploaddesigns.vue'; // 上传设计
import OrderSend from './ordersend.vue'; // 物流
export default {
  
  // 案例订单
  name: 'CaseOrder',
  components: {
    UploadDesigns,
    OrderSend,
  },

  data() {
    return {
      dateTime: [],
      form: {
        creator: '',
        startTime: '', // 开始时间
        endTime: '', // 结束时间
        doctorName: '', // 公共字段
        createDeptName: '', // 诊所
        skillDeptName: '', // 技工所
        patientName: '', // 患者
        orderTypeName: '', // 类型
        orderDataType: '', // 类型 1: 牙齿修复  2: 牙齿种植  3: 牙齿正畸
        orderDesignStatus: '',
        orderStatus: 99, // 订单状态
        page: 1, // 默认第1页
        limit: 10, // 每页条数
      },
      timer: null,
      // 类型选择
      cateOptions: [
        { label: this.$t('add.add159'), value: '1' },
        { label: this.$t('add.add160'), value: '2' },
        { label: this.$t('add.add161'), value: '3' },
      ],
      multipleSelection: [],
      tableData: [],
      total: 0, // 总条数
      activeName: 'quanbu',
      jgsform: {
        // 下单
        id: '',
        skillDeptId: null,
      },
      // jgsdialogShow: false, // 技工所是否展示
      deptList: [], // 技工所数据
      user_roleId: '', // 权限id
      user_organizedType: '',
      pickerOptions: {
        shortcuts: [
          {
            text: this.$t('add.add155'),
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit('pick', [start, end]);
            },
          },
          {
            text: this.$t('add.add156'),
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit('pick', [start, end]);
            },
          },
          {
            text: this.$t('add.add157'),
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 120);
              picker.$emit('pick', [start, end]);
            },
          },
          {
            text: this.$t('add.add158'),
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 365);
              picker.$emit('pick', [start, end]);
            },
          },
        ],
      },
      user_owner: '',
      orderDesignAutoCheck: '',
      user_deptId: '', // 机构id
      // 控制重新生成弹框展示
      dialogVisible: false,
      currRow: {},
    };
  },


  created() {
    // 获取本地缓存的搜索条件
    this.getCacheCondition();
    this.getSelectPageListData();
    this.timer = setInterval(() => {
      this.getSelectPageListData();
    }, 10 * 1000);
    this.getDeptList();
  },
  mounted() {
    this.user_deptId = localStorage.getItem('user_deptId');
    this.user_owner = localStorage.getItem('user_owner');
    this.user_roleId = window.localStorage.getItem('user_roleId');
    this.user_organizedType = window.localStorage.getItem('user_organizedType');
    if (!window.localStorage.getItem('user_jg_id')) {
      this.$http
        .get('/sys/organized/getOptionLabel')
        .then(({ data: res }) => {
          if (res.code !== 0) {
            return this.$message.error(res.msg);
          } else {
            res.data.forEach((item) => {
              if (item.currentDept) {
                window.localStorage.setItem('user_jg_id', item.id);
                this.getOrganized();
              }
            });
          }
        })
        .catch((err) => {
          console.log('err', err);
        });
    } else {
      this.getOrganized();
    }

    this.$clacTableHeight();
  },
  methods: {
    getCacheCondition() {
      let data = JSON.parse(window.localStorage.getItem('caseorderData'));
      if(!data || !data.isCaseOrderDetail){
        return false;
      }
      let user_jg_id = window.localStorage.getItem('user_jg_id');
      let user_id = window.localStorage.getItem('user_id');
      if (user_jg_id === data.user_jg_id && user_id === user_id) {
        // 就说明是同一个用户同个机构缓存的条件
        this.form.doctorName = data.doctorName;
        this.form.skillDeptName = data.skillDeptName;
        this.form.creatorDeptName = data.creatorDeptName;
        this.form.patientName = data.patientName;
        this.form.orderDataType = data.orderDataType;
        this.dateTime = data.dateTime;
      }
    },
    // 将筛选条件缓存到本地
    toCacheCondition() {

      // 获取本地的用户id和机构id 方便下次预设查询条件
      let user_jg_id = window.localStorage.getItem('user_jg_id');
      let user_id = window.localStorage.getItem('user_id');
      let data = {
        user_jg_id,
        user_id,
        doctorName: this.form.doctorName,
        skillDeptName: this.form.skillDeptName,
        creatorDeptName: this.form.creatorDeptName,
        patientName: this.form.patientName,
        orderDataType: this.form.orderDataType,
        dateTime: this.dateTime,
        isCaseOrderDetail: false,
      };
      window.localStorage.setItem('caseorderData', JSON.stringify(data));
    },
    getSelectPageListData() {
      if (this.$route.query.id) {
        this.form.creator = this.$route.query.id;

        this.form.caseMembers = this.$route.query.caseMembers;
        this.getSelectPageList();
      } else {
        if (sessionStorage.getItem('hcyl_page')) {
          this.form.page = Number(sessionStorage.getItem('hcyl_page'));
          this.getSelectPageList();
        } else {
          this.getSelectPageList();
        }
      }
    },
    // 拒绝接单
    orderReject(id) {
      let jurisdictionIsShow = localStorage.getItem('user_auditReportState');
      // 定义一个变量通知是否跳转到里面去确认接单
      let isJump = false;
      if (jurisdictionIsShow) {
        if (jurisdictionIsShow == '1') {
          isJump = true;
        }
      }
      if (isJump) {
        this.$router.push(`/caseOrderDetail?id=${id}&isAudit=true&isConfirm=false`);
      } else {
        this.$confirm(this.$t('caseorder.anli103'), {
          confirmButtonText: this.$t('add.add142'),
          cancelButtonText: this.$t('add.add143'),
          type: 'warning',
        }).then(() => {
          this.$http
            .post('/order/orderReject', { id: id })
            .then(({ data: res }) => {
              if (res.code !== 0) {
                return this.$message.error(res.msg);
              } else {
                this.$message.success(this.$t('add.add26'));
                this.getSelectPageList();
              }
            })
            .catch((err) => {
              console.log('err', err);
            });
        });
      }
    },
    // 确认接单
    orderAffirm(row) {
      let jurisdictionIsShow = localStorage.getItem('user_auditReportState');
      // 定义一个变量通知是否跳转到里面去确认接单
      let isJump = false;
      if (jurisdictionIsShow) {
        if (jurisdictionIsShow == '1') {
          isJump = true;
        }
      }
      if (isJump) {
        this.$router.push(`/caseOrderDetail?id=${row.id}&isAudit=true&isConfirm=true`);
      } else {
        this.$confirm(this.$t('caseorder.anli102'), {
          confirmButtonText: this.$t('add.add142'),
          cancelButtonText: this.$t('add.add143'),
          type: 'warning',
        }).then(() => {
          this.$http
            .post('/order/orderAffirm', {
              id: row.id,
              orderDesignAutoCheck: row.orderDesignAutoCheck,
            })
            .then(({ data: res }) => {
              if (res.code !== 0) {
                return this.$message.error(res.msg);
              } else {
                this.$message.success(this.$t('add.add27'));
                this.getSelectPageList();
              }
            })
            .catch((err) => {
              console.log('err', err);
            });
        });
      }
    },
    getOrganized() {
      // console.log('订单页面------------',localStorage.getItem('user_jg_id'));
      // this.$http
      //   .get(`/sys/organized/${localStorage.getItem('user_jg_id')}`)
      //   .then(({ data: res }) => {
      //     if (res.code !== 0) {
      //       return this.$message.error(res.msg);
      //     } else {
      //       this.orderDesignAutoCheck = res.data.orderDesignAutoCheck;
      //     }
      //   })
      //   .catch((err) => {
      //     console.log('err', err);
      //   });
    },
    // 重置
    resetClick() {
      this.form = {
        startTime: '', // 开始时间
        endTime: '', // 结束时间
        doctorName: '', // 公共字段
        createDeptName: '', // 诊所
        skillDeptName: '', // 技工所
        patientName: '', // 患者
        orderTypeName: '', // 类型
        orderDataType: '', // 类型 1: 牙齿修复  2: 牙齿种植  3: 牙齿正畸
        orderStatus: 99,
        page: 1, // 默认第1页
        limit: 10, // 每页条数
      };
      this.dateTime = [];
      this.total = 0;
      this.getSelectPageList();
    },
    tabHandleClick(tab) {
      if (tab.name == 'quanbu') {
        this.form.orderStatus = null;
        this.form.orderDesignStatus = '';
        this.form.orderLogisticsStatus = '';
        this.getSelectPageList();
      } else if (tab.name == 'zancun') {
        this.form.orderStatus = 0;
        this.form.orderDesignStatus = '';
        this.form.orderLogisticsStatus = '';
        this.getSelectPageList();
      } else if (tab.name == 'daijiedan') {
        this.form.orderStatus = 1;
        this.form.orderDesignStatus = '';
        this.form.orderLogisticsStatus = '';
        this.getSelectPageList();
      } else if (tab.name == 'yijiedan') {
        this.form.orderStatus = 2;
        this.form.orderDesignStatus = '';
        this.form.orderLogisticsStatus = '';
        this.getSelectPageList();
      } else if (tab.name == 'daiquerenseji') {
        this.form.orderStatus = 3;
        this.form.orderDesignStatus = 'EXIST';
        this.form.orderLogisticsStatus = '';
        this.getSelectPageList();
      } else if (tab.name == 'daisheji') {
        this.form.orderStatus = 3;
        this.form.orderDesignStatus = 'AGAIN';
        this.form.orderLogisticsStatus = '';
        this.getSelectPageList();
      } else if (tab.name == 'yiquerensheji') {
        this.form.orderStatus = 3;
        this.form.orderDesignStatus = 'AFFIRM';
        this.form.orderLogisticsStatus = '';
        this.getSelectPageList();
      } else if (tab.name == 'daifahuo') {
        this.form.orderStatus = 8;
        this.form.orderDesignStatus = '';
        this.form.orderLogisticsStatus = 'AGAIN';
        this.getSelectPageList();
      } else if (tab.name == 'daishouhuo') {
        this.form.orderStatus = 8;
        this.form.orderDesignStatus = '';
        this.form.orderLogisticsStatus = 'EXIST';
        this.getSelectPageList();
      } else if (tab.name == 'yiwancheng') {
        this.form.orderStatus = 6;
        this.form.orderDesignStatus = '';
        this.form.orderLogisticsStatus = '';
        this.getSelectPageList();
      } else if (tab.name == 'yiquxiao') {
        this.form.orderStatus = 5;
        this.form.orderDesignStatus = '';
        this.form.orderLogisticsStatus = '';
        this.getSelectPageList();
      } else if (tab.name == 'yijujue') {
        this.form.orderStatus = 4;
        this.form.orderDesignStatus = '';
        this.form.orderLogisticsStatus = '';
        this.getSelectPageList();
      }
    },
    // 当选择发生变化时
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    // 序号显示
    indexMethod(index) {
      return index + 1;
    },
    // 获取技工列表
    getDeptList() {
      this.$http
        .get('/sys/organized/getOrganizedList?organizedType=2')
        .then(({ data: res }) => {
          if (res.code !== 0) {
            return this.$message.error(res.msg);
          } else {
            this.deptList = res.data;
          }
        })
        .catch((err) => {
          console.log('err', err);
        });
    },
    // 订单处理
    orderHandle(index, row, type) {
      this.currRow = row;
      if (type == 'see') {
        let isOverdue = false;
        if (row.markStatus !== 1) {
          isOverdue = true;
        }
        // 预览
        this.$router.push(`/caseOrderDetail?id=${row.id}&isOverdue=${isOverdue}`);
        localStorage.setItem('active_name', 'first');
      } else if (type == 'upload') {
        // 上传设计
        this.$refs.uploaddesigns.form.id = row.id;
        this.$refs.uploaddesigns.dialogShow = true;
        this.$refs.uploaddesigns.uploadPercentage = 0;
      } else if (type == 'send') {
        // 发货
        this.$refs.ordersend.form.id = row.id;
        this.$refs.ordersend.dialogShow = true;
      } else if (type == 'xiadan') {
        // this.jgsdialogShow = true;
        // this.jgsform.id = row.id;

        if (row.markStatus !== 1) {
          this.dialogVisible = true;
        } else {
          this.$router.push(`/caseOrderDetail?id=${row.id}&isExamine=true&submitOverdue=false`);
        }

        // 下单
      } else if (type == 'cancle') {
        // 取消订单
        this.$confirm(this.$t('add.add28') + '?', this.$t('add.add140'), {
          confirmButtonText: this.$t('add.add142'),
          cancelButtonText: this.$t('add.add143'),
          type: 'warning',
        })
          .then(async () => {
            this.$http
              .post('/order/orderCancel', { id: row.id })
              .then(({ data: res }) => {
                if (res.code !== 0) {
                  return this.$message.error(res.msg);
                } else {
                  this.$message.success(this.$t('add.add32'));
                  this.getSelectPageList();
                }
              })
              .catch((err) => {
                console.log('err', err);
              });
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: this.$t('add.add145'),
            });
          });
      } else if (type == 'delete') {
        // 删除订单
        this.$confirm(this.$t('add.add34'), this.$t('add.add140'), {
          confirmButtonText: this.$t('add.add142'),
          cancelButtonText: this.$t('add.add143'),
          type: 'warning',
        })
          .then(async () => {
            this.$http
              .post('/order/orderDelete', { id: row.id })
              .then(({ data: res }) => {
                if (res.code !== 0) {
                  return this.$message.error(res.msg);
                } else {
                  this.$message.success(this.$t('add.add66'));
                  this.getSelectPageList();
                }
              })
              .catch((err) => {
                console.log('err', err);
              });
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: this.$t('add.add145'),
            });
          });
      }
    },
    // 点击下单按钮
    submitHandle() {
      this.$http
        .post('/order/orderPlaceAnOrder', this.jgsform)
        .then(({ data: res }) => {
          if (res.code !== 0) {
            return this.$message.error(res.msg);
          } else {
            this.$message.success(this.$t('add.add36'));
            this.getSelectPageList();
            // this.jgsdialogShow = false;
            this.jgsform = {
              id: '',
              skillDeptId: null,
            };
          }
        })
        .catch((err) => {
          console.log('err', err);
        });
    },
    // 设计管理
    handleCommand(command) {
      let url;
      if (command.command == 'a') {
        url = '/order/orderAffirmDesign';
      } else if (command.command == 'b') {
        url = '/order/orderAgainDesign';
      } else if (command.command == 'c') {
        url = '/order/orderAffirmLogistics';
      } else if (command.command == 'd') {
        url = '/order/orderAgainLogistics';
      }
      this.$http
        .post(url, { id: command.id })
        .then(({ data: res }) => {
          if (res.code !== 0) {
            return this.$message.error(res.msg);
          } else {
            this.$message.success(this.$t('add.add37'));
            this.getSelectPageList();
          }
        })
        .catch((err) => {
          console.log('err', err);
        });
    },
    beforeHandleCommand(id, command) {
      return {
        id: id,
        command: command,
      };
    },
    getSelectPageList(val) {

      if (val == 1) {
        val = val;
      } else {
        val = 0;
      }
      this.toCacheCondition();
      if (this.dateTime && this.dateTime.length > 0) {
        this.form.startTime = this.dateTime[0];
        this.form.endTime = this.dateTime[1];
      } else {
        this.form.startTime = '';
        this.form.endTime = '';
      }
      if (!this.form.creator) {
        this.form.creator = '';
      }
      let param = {
        hasNews: val,
        page: this.form.page,
        limit: this.form.limit,
        orderStatus: this.form.orderStatus,
        doctorName: this.form.doctorName,
        orderDataType: this.form.orderDataType,
        creator: this.form.creator,
        startTime: this.form.startTime,
        endTime: this.form.endTime,
        timeZone: this.$timeZone,
        skillDeptName: this.form.skillDeptName,
        creatorDeptName: this.form.creatorDeptName,
        patientName: this.form.patientName,
        orderDesignStatus: this.form.orderDesignStatus,
        orderLogisticsStatus: this.form.orderLogisticsStatus,
        caseMembers: this.form.caseMembers,
      };
      this.$http
        .get('/order/selectPageList', {
          params: param,
        })
        .then(({ data: res }) => {
          if (res.code !== 0) {
            return this.$message.error(res.msg);
          } else {
            this.tableData = res.data.list;
            this.total = res.data.total;
            if (this.tableData.length <= 0 && this.form.page > 1) {
              this.form.page -= 1;
              this.getSelectPageList();
            }
          }
        })
        .catch((err) => {
          console.log('err', err);
        });
    },
    handleSizeChange(val) {
      this.form.limit = val;
      this.getSelectPageList();
    },
    handleCurrentChange(val) {
      this.form.page = val;
      sessionStorage.setItem('hcyl_page', Number(this.form.page));
      this.getSelectPageList();
    },
    toDownload() {
      this.$router.push(`/caseOrderDetail?id=${this.currRow.id}&isExamine=true&isOverdue=true`);
    },
  },
  beforeDestroy() {
    clearInterval(this.timer);
    this.timer = null;
    let data =  JSON.parse(window.localStorage.getItem('caseorderData'));
    data.isCaseOrderDetail = false;
    window.localStorage.setItem('caseorderData', JSON.stringify(data));
  },
};
</script>

<style lang="scss">
// .order_card{
// }
.el-tabs--border-card>.el-tabs__content {
  padding: 0;
  display: none;
}

.el-tabs--border-card {
  border: none;
}

.el-dropdown-link {
  cursor: pointer;
  font-size: 12px;
  font-weight: 400;
  line-height: 20px;
  color: #003e67;
}

.el-icon-arrow-down {
  font-size: 12px;
}

.el-button,
.el-button+.el-button {
  margin-left: 0 !important;
  margin-right: 10px !important;
}

.el-tabs--border-card>.el-tabs__header .el-tabs__item,
.el-table thead {
  font-size: 14px;
  font-weight: bolder;
  color: rgb(49, 48, 48);
  background: rgb(248, 248, 249);
  font-family: PingFangSC-Medium, 'PingFang SC';
}
</style>
